package com.example.tao.mycar.login;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.tao.mycar.MyActionBarActivity;
import com.example.tao.mycar.MyApplication;
import com.example.tao.mycar.R;

public class SetPasswordActivity extends MyActionBarActivity implements View.OnClickListener {

    private EditText password;
    private Button nextButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MyApplication.getInstance().addActivity(this);
        setContentView(R.layout.activity_set_password);
        setToolBar(getResources().getString(R.string.title_activity_set_password), true);

        password = (EditText) this.findViewById(R.id.input_password);
        nextButton = (Button) this.findViewById(R.id.next_step);

        nextButton.setOnClickListener(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.next_step :
                String passwordStr = password.getText().toString();
                if (TextUtils.isEmpty(passwordStr)) {
                    Toast.makeText(SetPasswordActivity.this, R.string.input_phone_number, Toast.LENGTH_LONG).show();
                } else {
                    MyApplication.setPassword(passwordStr);
                    Intent intent = new Intent(this, SetBabySexActivity.class);
                    startActivity(intent);
                }
                break;
            default:
                break;
        }
    }
}
